﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Drawing;
using System.Diagnostics;

using Microsoft.WindowsMobile.Status;

using iPhoneUI.Shell;

namespace iPhoneUI.Widgets
{
    public class MessagingStatus : Widget
    {
        public MessagingStatus()
        {
            ButtonSize = 24;
        }

        protected override void OnSetOwner()
        {
            foreach (MessagingStatusItem item in Decorations.OfType<MessagingStatusItem>())
                item.Image = ShellConfig.CreatePerPixelAlphaImage(item.ImageName);

            base.OnSetOwner();
        }

        public int ButtonSize { get; set; }

        protected override void Layout()
        {
            int i = 0;
            foreach (Widget w in Decorations.OfType<MessagingStatusItem>())
            {
                if (i == 0)
                    w.Location = Location;
                else if (i == 1)
                    w.Location = new Point(ClientArea.Right - w.Size.Width, Location.Y);
                else if (i == 2)
                    w.Location = new Point(ClientArea.Right - w.Size.Width, ClientArea.Bottom - w.Size.Height);
                else
                    w.Location = new Point(Location.X, ClientArea.Bottom - w.Size.Height);

                i++;
            }

            base.Layout();
        }

        public override void LayoutAsDecoration(Rectangle reference)
        {
            ClientArea = reference;

            base.LayoutAsDecoration(reference);
        }
        protected override void OnDraw(Canvas canvas, Rectangle clipBounds)
        {
            // this widget doesn't do any of its own drawing - 
        }
    }
}
